package com.boot2.core.model.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
* @author zhangweilin
* @date 2020/10/10 18:00
* @Description:  文件目录树
*/
@ApiModel("文件目录树节点")
@Data
@EqualsAndHashCode(callSuper = false)
public class FileTreeNode {

    @ApiModelProperty(value = "文件名")
    private String name;

    @ApiModelProperty(value = "路径")
    private String path;

    @ApiModelProperty(value = "文件大小")
    private Long length;

    @ApiModelProperty(value = "是否是目录（文件夹）")
    private Boolean isDir = false;//是否文件夹

    @ApiModelProperty(value = "最后修改时间")
    private Date lastModified;

    @ApiModelProperty(value = "子文件列表")
    private List<FileTreeNode> children = new ArrayList<>();
 
    public void addChild(FileTreeNode treeNode) {
        if (children == null) {
            children = new ArrayList<>();
        }
        children.add(treeNode);
    }
}